using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using TimeTableManagement.Entities;

namespace TimeTableManagement.Mapping
{
    public class Tb_EducationMap : EntityTypeConfiguration<Tb_Education>
    {
        public Tb_EducationMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.code)
                .HasMaxLength(20);

            this.Property(t => t.name)
                .HasMaxLength(255);

            this.Property(t => t.description)
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("Tb_Education");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.code).HasColumnName("code");
            this.Property(t => t.name).HasColumnName("name");
            this.Property(t => t.maxcredit).HasColumnName("maxcredit");
            this.Property(t => t.countterm).HasColumnName("countterm");
            this.Property(t => t.department).HasColumnName("department");
            this.Property(t => t.listcourse).HasColumnName("listcourse");
            this.Property(t => t.description).HasColumnName("description");

            // Relationships
            this.HasOptional(t => t.Tb_Department)
                .WithMany(t => t.Tb_Education)
                .HasForeignKey(d => d.department);

        }
    }
}

